package com.apes.fn.tms.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.util.ApesConst;
import com.apes.scm.masterdata.enumeration.model.Enumeration;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

/**
 * 功能：车辆管理
 *
 * @author Linwz
 * @create 2020-03-06 9:46
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Vehicle.CONST_TABLE_NAME)
public class Vehicle extends Model {
    public static final String CONST_TABLE_NAME = "tms_vehicle";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "车辆管理")
    @Comment("编码")
    private String id;


    @Name
    @Column(name = "vehicle_number", length = 30)
    @Comment("车牌号")
    private String vehicleNumber;

    @Column(name = "vehicle_model", length = 30)
    @Comment("车型")
    private String vehicleModel;

    @Column(name = "restricted_hours", length = 30)
    @Comment("限行时段")
    private String restrictedHours;

    @Column(name = "lengthV", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("车身长度")
    private double lengthV = 0;

    @Column(name = "widthV", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("车身宽度")
    private double widthV = 0;

    @Column(name = "heightV", nullable = false, columnDefinition = ApesConst.FIELD_MONEY_16_4_0)
    @Comment("车身高度")
    private double heightV = 0;

    @Name
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "vehicle_status",referencedColumnName = "id")
    private Enumeration vehicleStatus; // 车辆状态 （0：正常在用:1：已报废）

    @Column(name = "valid", nullable = false)
    @Comment("有效")
    private boolean valid ; //有效
}
